home *** CD-ROM | disk | FTP | other *** search
/ Apple Reference & Presen…rary 8 (Internal Edition) / Apple R&P Lib Internal v8.0.iso / 5-Fonts & Software / Demo Software / Canvas 3.0 Demo / Canvas 3.0 Tools / Separations / Separations.rsrc / hd11_1010_CvHeader < prev    next >
Text File  |  1990-06-24  |  12KB  |  295 lines

  1. %%BeginProcSet:Canvas_header
  2. /CanvasDict 250 dict def
  3. CanvasDict begin
  4. systemdict/setpacking known{/origpack currentpacking def true setpacking}if
  5. /bdf{bind def}bind def
  6. /xdf{exch bind def}bdf
  7. /min{2 copy gt{exch}if pop}bdf
  8. /edf{exch def}bdf
  9. /max{2 copy lt{exch}if pop}bdf
  10. /cvmtx matrix def
  11. /currot 0 def
  12. /rotmtx matrix def
  13. /origmtx matrix def
  14. /cvangle{360 exch sub 90 add 360 mod}bdf
  15. /setrot{/currot edf rotmtx currentmatrix pop 2 copy translate currot rotate neg exch neg exch translate}bdf
  16. /endrot{rotmtx setmatrix}bdf
  17. /patspot{1 add 4 mul cvi exch 1 add 4 mul cvi exch patstr exch get exch 7 exch sub 1 exch bitshift and 0 ne{1}{0}ifelse}bdf
  18. /f/fill load def
  19. /s{1 setlinewidth penh penv scale stroke}bdf
  20. /i systemdict /image get def/T true def/F false def/dbg F def
  21. /ncolors 0 def/st0 ()def/st1 ()def/proc0 {}def
  22. /penh 0 def/penv 0 def/penv2 0 def/penh2 0 def/samplesize 0 def/width 0 def/height 0 def
  23. /SpaceExtra 0 def/LetterSpace 0 def/StringLength 0 def/NumSpaces 0 def/JustOffset 0 def
  24. /icomp    % images a color composite. approximates for b&w printer
  25. {
  26.     /ncolors edf
  27.     ncolors 1 gt
  28.     { %multiple color depth
  29.         /proc0 edf
  30.         dup dup 0 get ncolors div cvi
  31.         exch 0 3 -1 roll put
  32.         4 -1 roll ncolors div cvi 4 1 roll
  33.         ncolors 3 eq
  34.         {% rgb values
  35.             {
  36.                 proc0 dup/st0 edf
  37.                 0 exch %start
  38.                 3 exch %increment
  39.                 length %size of string
  40.                 dup 3 sub exch 3 div cvi string/st1 edf %destination string
  41.                 {
  42.                     dup    %remember start index
  43.                     0 exch % accumulator at bottom
  44.                     dup % duplicate index
  45.                     1 exch %increment
  46.                     2 add %end at index+ 2
  47.                     {st0 exch get add}for    %only support 8 bits per sample
  48.                     3 div cvi % average rgb get 1 value
  49.                     dup 255 gt{pop 255}if
  50.                     exch 3 div cvi exch %knock down index to dest value
  51.                     st1 3 1 roll put
  52.                 }for
  53.                 st1    %leave string on stack
  54.             }    %image proc definition
  55.         }
  56.         {% cmyk values
  57.             {
  58.                 proc0 dup/st0 edf
  59.                 0 exch %start
  60.                 4 exch %increment
  61.                 length %size of string
  62.                 dup 4 sub exch 4 div cvi string/st1 edf %destination string
  63.                 {
  64.                     dup    %remember start index
  65.                     0 exch % accumulator at bottom
  66.                     dup % duplicate index
  67.                     1 exch %increment
  68.                     2 add %end at index+ 2
  69.                     {st0 exch get add}for    %only support 8 bits per sample
  70.                     3 div % average rgb get 1 value
  71.                     exch dup 3 1 roll 3 add st0 exch get add cvi %retrieve black value
  72.                     dup 255 gt{pop 255}if
  73.                     exch 4 div cvi exch %knock down index to dest value
  74.                     st1 3 1 roll put
  75.                 }for
  76.                 st1    %leave string on stack
  77.             }    %iproc definition
  78.         }ifelse
  79.     }if    % more that 1 color
  80.     i
  81. }bdf
  82. /ci    %general routine for generating a color image
  83. {
  84.     /colorimage where
  85.     {pop false exch colorimage} %use existing colorimage
  86.     {icomp} %approximate with image command
  87.     ifelse
  88. }bdf
  89. %%
  90. %%    This routine redefines /s and /f (stroke and fill) to perform image patterns
  91. %%
  92. /spat
  93. {
  94.     /patstr edf
  95.     /ncolors edf
  96.     /s{ matrix currentmatrix
  97.         1 setlinewidth penh penv scale
  98.         25 setflat    %for curves this reduced number of points
  99.         strokepath
  100.         setmatrix
  101.         impat
  102.     }def
  103.     /f{impat}def
  104. }bdf
  105. /impat        %% impat  to be used in place of stroking or filling
  106. {
  107.     /samplesize 8 ncolors mul def    % number of bytes per row of pattern
  108.     /cnt 0 def                        % current row count
  109.     currot neg rotate
  110.     clip
  111.     flattenpath
  112.     pathbbox
  113.     3 -1 roll
  114.     dup /starty edf
  115.     sub abs 8 div ceiling 8 mul cvi /height edf
  116.     exch dup /startx edf
  117.     sub abs samplesize div ceiling samplesize mul cvi /width edf
  118.     startx starty translate
  119.     width height scale
  120.     /st0 width ncolors mul string def
  121.     width height 8 [width 0 0 height neg 0 height]
  122.     {
  123.         patstr                    %string
  124.         cnt 8 mod samplesize mul    %index
  125.         samplesize                %count
  126.         getinterval
  127.         /st1 edf
  128.         0
  129.         samplesize
  130.         st0 length samplesize sub dup 0 le{pop 1}if
  131.         {st0 exch
  132.             st1
  133.             putinterval
  134.         } for
  135.         /cnt cnt 1 add def
  136.         st0
  137.     }bind
  138.     ncolors
  139.     dup 1 eq {icomp}{ci}ifelse
  140.     newpath    % we'll act just like stroke/fill and elimate the current path
  141. }bdf
  142. %%    images an 8 bits/sample color image where color data
  143. %%    is interlaced ie xxxxxx or RRGGBB or CCMMYYKK
  144. %%
  145. %%    width height sx sy tx ty ncolors cm
  146. /cm{
  147.     /ncolors edf
  148.     translate
  149.     scale
  150.     /height edf
  151.     /width edf
  152.     /tbitstr width string def
  153.     width height 8 [width 0 0 height neg 0 height]
  154.     {currentfile tbitstr readhexstring pop}bind
  155.     ncolors
  156.     dup 3 eq {ci}{icomp}ifelse
  157. }bdf
  158. %%    images a 1 bit/sample image given height,width and image data
  159. /im{    %%  width height sw sh tx ty im -hexdata-
  160.     translate
  161.     scale
  162.     /height edf
  163.     /width edf
  164.     /tbitstr width 7 add 8 div cvi string def
  165.     width height 1 [width 0 0 height neg 0 height]
  166.     {currentfile tbitstr readhexstring pop}bind
  167.     i
  168. }bdf
  169. /imk{    %% width height sw sh tx ty flag imk
  170.     /invFlag edf
  171.     translate
  172.     scale
  173.     /height edf
  174.     /width edf
  175.     /tbitstr width 7 add 8 div cvi string def
  176.     width height invFlag [width 0 0 height neg 0 height]
  177.     {currentfile tbitstr readhexstring pop}bind
  178.     imagemask
  179. }bdf
  180. /BeginEPSF
  181. {
  182.     /MySave save def
  183.     /dict_count countdictstack def
  184.     /op_count count 1 sub def
  185.     userdict begin
  186.     /showpage {} def
  187.     0 setgray 0 setlinecap
  188.     1 setlinewidth 0 setlinejoin
  189.     10 setmiterlimit [] 0 setdash newpath
  190.     /languagelevel where
  191.     {pop languagelevel 1 ne{false setstrokeadjust false setoverprint}if}if
  192. }bdf
  193. /EndEPSF
  194. {
  195.     count op_count sub {pop}repeat
  196.     countdictstack dict_count sub {end}repeat
  197.     MySave restore
  198. }bdf
  199. /setpat {1 currenttransfer exec 0 eq{exch pop{1 exch sub}}{pop{}}ifelse systemdict begin settransfer end /patstr edf 9.375 currot neg rotate 1 0 dtransform exch atan 0 1 dtransform exch pop 0 ge{180 add}if currot rotate/patspot load systemdict begin setscreen end}bdf
  200. systemdict/setcmykcolor known not{/setcmykcolor{/black edf 3{black add 1.0 exch sub 0.0 max 1.0 min 3 1 roll}repeat setrgbcolor}bdf}if
  201. /setpcol{/pgray edf systemdict/setcmykcolor known{/pgray 1 pgray sub def 4{0 eq{0}{pgray}ifelse 4 1 roll}repeat setcmykcolor}
  202. {setcmykcolor currentgray 1 ne{pgray}{1}ifelse setgray}ifelse}bdf
  203. /rectpath {/cv_r edf/cv_b edf/cv_l edf/cv_t edf
  204. cv_l cv_t moveto cv_r cv_t lineto cv_r cv_b lineto cv_l cv_b lineto cv_l cv_t lineto closepath}bdf
  205. /setpen {/penh edf/penv edf/penv2 penv 2 div def/penh2 penh 2 div def}bdf
  206. /dostroke{save /MySave edf not pens 1 currentgray ne or {s}if MySave restore}def
  207. /dodashfill{save /MySave edf not fills 1 currentgray ne or {gsave f grestore [] 0 setdash s}if MySave restore}def
  208. /dofill{save /MySave edf not fills 1 currentgray ne or {f}if MySave restore}def
  209. /doline{save /MySave edf not pens 1 currentgray ne or {f}if MySave restore}def
  210. /pmov{penv2 add exch penh2 sub exch moveto}bdf/plin{penv2 add exch penh2 sub exch lineto}bdf
  211. /linpath{/cv_b edf/cv_r edf/cv_t edf/cv_l edf penh2 dup cv_r exch sub/cv_r edf
  212. cv_l exch sub/cv_l edf penv2 dup cv_b add/cv_b edf cv_t add/cv_t edf cv_r cv_l gt
  213. {cv_b cv_t lt{cv_l cv_t moveto penh 0 rlineto cv_r penh add cv_b lineto 0 penv neg rlineto penh neg 0 rlineto
  214. cv_l cv_t penv neg add lineto}{cv_l cv_t moveto cv_r cv_b lineto penh 0 rlineto 0 penv neg rlineto
  215. cv_l penh add cv_t penv neg add lineto penh neg 0 rlineto 0 penv rlineto}ifelse}{cv_b cv_t lt{
  216. cv_l cv_t moveto cv_r cv_b lineto 0 penv neg rlineto penh 0 rlineto cv_l penh add cv_t penv neg add lineto 0 penv rlineto penh neg 0 rlineto}{
  217. cv_l penh add cv_t moveto cv_r penh add cv_b lineto penh neg 0 rlineto 0 penv neg rlineto
  218. cv_l cv_t penv neg add lineto penh 0 rlineto 0 penv rlineto}ifelse}ifelse closepath}bdf
  219. /dopline {/cv_pv edf/cv_ph edf currentpoint cv_ph cv_pv linpath doline newpath cv_ph cv_pv moveto}bdf
  220. /spx{SpaceExtra 0 32 4 -1 roll widthshow}bdf
  221. /lsx{SpaceExtra 0 32 LetterSpace 0 6 -1 roll awidthshow}bdf
  222. /Rjust{stringwidth pop JustOffset exch sub /JustOffset edf}bdf
  223. /Cjust{stringwidth pop 2 div JustOffset exch sub /JustOffset edf}bdf
  224. /adjfit{stringwidth pop LetterSpace StringLength 1 sub mul add SpaceExtra NumSpaces mul add dup /pw edf JustOffset exch 
  225. sub dup /wdif edf StringLength div LetterSpace add /LetterSpace edf}bdf
  226. /ulb{currentpoint pop /underlinpt edf}bdf
  227. /ule{gsave currentpoint newpath moveto currentfont dup /ft1 known{dup /ft1 get begin /FontMatrix get FontMatrix tpmx concatmatrix pop}
  228. {begin FontMatrix tpmx copy pop}ifelse FontInfo begin UnderlinePosition UnderlineThickness end end dup tpmx
  229. dtransform pop setlinewidth dup tpmx dtransform pop 0 exch rmoveto underlinpt currentpoint pop sub 0 rlineto stroke grestore}bdf
  230. /fittext{ /SpaceExtra edf /LetterSpace edf /StringLength edf /NumSpaces edf /JustOffset edf not 1 currentgray ne or
  231. {dup {ulb}if exch
  232. dbg not {dup adjfit}if
  233. lsx {ule}if}{pop pop}ifelse}bdf
  234. %% debugging aid
  235. /Debug{ gsave /Times-Roman findfont 8 scalefont setfont
  236.     gsave 0 -2 rmoveto ( adj= ) show wdif 32 string cvs show grestore
  237.     gsave 0 6 rmoveto ( width= ) show pw 32 string cvs show grestore
  238.     gsave 65 -2 rmoveto (lsp= ) show LetterSpace 32 string cvs show grestore
  239.     gsave 65 6 rmoveto (spx= ) show SpaceExtra 32 string cvs show grestore
  240.     grestore
  241. }bdf
  242. %%
  243. /cvRecFont{/encod edf FontDirectory 2 index known{cleartomark}{findfont dup length 1 add dict begin
  244. {1 index/FID ne{def}{pop pop}ifelse}forall encod{/Encoding CVvec def}if
  245. currentdict end definefont cleartomark}ifelse}bdf
  246. /wrk1 ( ) def/wdict 16 dict def
  247. /Work75 75 string def /Nmk{Work75 cvs dup}bdf /Npt{put cvn}bdf /dhOdh{Nmk 2 79 Npt}bdf /dhodh{Nmk 2 111 Npt}bdf    /dhSdh{Nmk 2 83 Npt}bdf
  248. /sfWidth{gsave 0 0 moveto 0 0 lineto 0 0 lineto 0 0 lineto closepath clip stringwidth grestore}bdf
  249. /MakOF{dup dhodh FontDirectory 1 index known{exch pop}{exch findfont dup length 1 add dict begin
  250. {1 index/FID ne 2 index /UniqueID ne and{def}{pop pop}ifelse}forall
  251. /PaintType 2 def
  252. /StrokeWidth .24 1000 mul ftSize div dup 12 lt{pop 12}if def
  253. dup currentdict end definefont pop}ifelse}bdf
  254. /fts{dup/ftSize edf}def
  255. /mkFT{/tempFT 11 dict def tempFT begin
  256. /FontMatrix [1 0 0 1 0 0] def/FontType 3 def
  257. FontDirectory 3 index get /Encoding get/Encoding exch def
  258. /proc2 edf/ft2 exch findfont def/ft1 exch findfont def/FontBBox [0 0 1 1] def
  259. /BuildChar{wdict begin/chr edf/ftdt edf/chrst wrk1 dup 0 chr put def ftdt/proc2 get exec end}def
  260. end tempFT definefont pop}bdf
  261. /OLFt{dup dhOdh FontDirectory 1 index known{exch pop}
  262. {dup 3 -1 roll dup MakOF {outproc} mkFT}ifelse}bdf
  263. /mshw{moveto show}bdf
  264. /outproc{ftdt/ft1 get setfont gsave chrst sfWidth grestore setcharwidth dblsh}bdf
  265. /dblsh{currentgray 1 setgray chrst 0 0 mshw setgray ftdt/ft2 get setfont chrst 0 0 mshw}bdf
  266. /ShadChar{ftdt/ft1 get setfont gsave chrst sfWidth 1 index 0 ne{exch .05 add exch}if grestore setcharwidth
  267. chrst .06 0 mshw 0 .05 translate dblsh}bdf
  268. /ShFt{dup dhSdh FontDirectory 1 index known{exch pop}
  269. {dup 3 -1 roll dup MakOF {ShadChar} mkFT}ifelse}bdf
  270. /LswUnits{72 75 div dup scale}bdf
  271. /erasefill{gsave 1.0 setgray fill grestore}bdf
  272. /tpmx matrix def
  273. /CVvec 256 array def
  274. /NUL/SOH/STX/ETX/EOT/ENQ/ACK/BEL/BS/HT/LF/VT/FF/CR/SO/SI/DLE/DC1/DC2/DC3/DC4/NAK/SYN/ETB/CAN/EM/SUB/ESC/FS/GS/RS/US
  275. CVvec 0 32 getinterval astore pop
  276. CVvec 32/Times-Roman findfont/Encoding get
  277. 32 96 getinterval putinterval CVvec dup 39/quotesingle put 96/grave put
  278. /Adieresis/Aring/Ccedilla/Eacute/Ntilde/Odieresis/Udieresis/aacute
  279. /agrave/acircumflex/adieresis/atilde/aring/ccedilla/eacute/egrave
  280. /ecircumflex/edieresis/iacute/igrave/icircumflex/idieresis/ntilde/oacute
  281. /ograve/ocircumflex/odieresis/otilde/uacute/ugrave/ucircumflex/udieresis
  282. /dagger/degree/cent/sterling/section/bullet/paragraph/germandbls
  283. /registered/copyright/trademark/acute/dieresis/notequal/AE/Oslash
  284. /infinity/plusminus/lessequal/greaterequal/yen/mu/partialdiff/summation
  285. /product/pi/integral/ordfeminine/ordmasculine/Omega/ae/oslash
  286. /questiondown/exclamdown/logicalnot/radical/florin/approxequal/Delta/guillemotleft
  287. /guillemotright/ellipsis/blank/Agrave/Atilde/Otilde/OE/oe
  288. /endash/emdash/quotedblleft/quotedblright/quoteleft/quoteright/divide/lozenge
  289. /ydieresis/Ydieresis/fraction/currency/guilsinglleft/guilsinglright/fi/fl
  290. /daggerdbl/periodcentered/quotesinglbase/quotedblbase/perthousand/Acircumflex/Ecircumflex/Aacute
  291. /Edieresis/Egrave/Iacute/Icircumflex/Idieresis/Igrave/Oacute/Ocircumflex
  292. /apple/Ograve/Uacute/Ucircumflex/Ugrave/dotlessi/circumflex/tilde
  293. /macron/breve/dotaccent/ring/cedilla/hungarumlaut/ogonek/caron
  294. CVvec 128 128 getinterval astore pop
  295.